package com.project.service.base.CrpData;

import com.project.entity.User;

import java.io.UnsupportedEncodingException;

import static com.project.service.cryptolib.SM4.ECB;

/**
 * author: WheelChen
 * date: 2017/7/16
 * <p>
 * 加解密数据
 */
public interface CrypDataHelper {

    //加解密模式
    int MODE = ECB;

    byte[] key = {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef,
            (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10};
    byte[] iv = {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef,
            (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10};

    /**
     * author: WheelChen
     * date: 2017/7/17
     * function: 加密邮箱
     *
     * @param email 邮箱
     * @return
     */
    String encryptEmail(String email) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/17
     * function: 加密邮箱
     *
     * @param mobilePhone 手机号
     * @return
     */
    String encryptMobilePhone(String mobilePhone) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/18
     * function: 加密真实姓名
     *
     * @param realName 真实姓名
     * @return
     */
    String encryptRealName(String realName) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/18
     * function: 加密所有数据
     *
     * @param data
     * @return
     */
    String encryptAll(String data) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/17
     * function: 解密邮箱
     *
     * @param email 邮箱
     * @return
     */
    String decEmail(String email) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/17
     * function: 解密邮箱
     *
     * @param mobilePhone 手机号
     * @return
     */
    String decMobilePhone(String mobilePhone) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/18
     * function: 解密真实姓名
     *
     * @param realName 真实姓名
     * @return
     */
    String decRealName(String realName) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/18
     * function: 解密所有数据
     *
     * @param data
     * @return
     */
    String decAll(String data) throws UnsupportedEncodingException;

    /**
     * author: WheelChen
     * date: 2017/7/17
     * function: 加密用户数据
     *
     * @param user
     * @return
     */
    void encryptUser(User user) throws Exception;

    /**
     * author: WheelChen
     * date: 2017/7/18
     * function: 解密用户
     *
     * @param user
     * @return
     */
    void decUser(User user) throws Exception;


}
